﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using NetCoreCMS.IServices;
using NetCoreCMS.Models;

namespace NetCoreCMS.Web.Areas.Web.Controllers
{
    public class RepasswordController : BaseController
    {
        public string action;
        public string username = string.Empty;
        public string code = string.Empty;
        public IUser_codeService _user_code { get; set; }
        public IActionResult Index()
        {
            action = Request.Query["action"];
            if (string.IsNullOrEmpty(action))
                action = "index";
            if (action == "mobile")
            {
                username = Request.Query["username"];
            }
            else if (action == "email")
            {
                code = Request.Query["code"];
                User_code model = _user_code.GetModel(code);
                if (model == null)
                {
                    return Redirect("/Web/Repassword/Index?action=error");
                }
                username = model.user_name;
            }
            ViewBag.action = action;
            ViewBag.code = code;
            ViewBag.username = username;
            return View();
        }
    }
}